import {always, buildMenu} from "@/utils/permission";

export function menuContract(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0150', 'contract', '/contract', 'noRedirect', 'Layout', '合同管理', 'contracts')
    o.children.push(menuContractConsole(permissionCodes))
    o.children.push(menuContractBasal(permissionCodes))
    o.children.push(menuContractBusiness(permissionCodes))
    o.children.push(menuContractExec(permissionCodes))
    o.children.push(menuContractIncomeExpenditure(permissionCodes))
    // o.children.push(menuContractReportForms(permissionCodes))
    return o
}

function menuContractConsole(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0205', 'contractConsole', 'contractConsole', '', 'contract/contractConsole', '控制台', 'dashboard')
    o.children = []
    return o
}

function menuContractBasal(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0151', 'basal', 'basal', 'noRedirect', 'ParentView', '基础档案', 'archives')
    o.children.push(buildMenu(permissionCodes, 'PD0157', 'contractType', 'contractType', '', 'contract/basal/contractType/index', '合同类型', 'contract_type'))
    o.children.push(buildMenu(permissionCodes, 'PD0158', 'contractCooperation', 'contractCooperation', '', 'contract/basal/contractCooperation/index', '往来单位', 'dealings'))
    o.children.push(buildMenu(permissionCodes, 'PD0159', 'contractFeetype', 'contractFeetype', '', 'contract/basal/contractFeetype/index', '合同费用类型', 'filetype'))
    o.children.push(buildMenu(permissionCodes, 'PD0160', 'contractProjflag', 'contractProjflag', '', 'contract/basal/contractProjflag/index', '项目标识', 'marking'))
    o.children.push(buildMenu(permissionCodes, 'PD0161', 'contractFundsource', 'contractFundsource', '', 'contract/basal/contractFundsource/index', '合同资金来源', 'fundsource'))
    o.children.push(buildMenu(permissionCodes, 'PD0197', 'contractSigner', 'contractSigner', '', 'contract/basal/contractSigner/index', '签订人', 'signer'))
    o.children.push(buildMenu(permissionCodes, 'PD0198', 'contractFiletype', 'contractFiletype', '', 'contract/basal/contractFiletype/index', '合同附件类型', 'filetype'))
    o.children.push(buildMenu(permissionCodes, 'PD0199', 'contractTemplate', 'contractTemplate', '', 'contract/basal/contractTemplate/index', '合同模版', 'template'))
    o.children.push(buildMenu(permissionCodes, always, 'contractTemplateEdit', 'contractTemplateEdit', '', 'contract/basal/contractTemplate/edit', '合同模版编辑', ''))
    return o
}

function menuContractBusiness(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0203', 'business', 'business', 'noRedirect', 'ParentView', '合同业务', 'initial')
    o.children.push(buildMenu(permissionCodes, 'PD0204', 'contractInitial', 'contractInitial', '', 'contract/business/contractInitial/index', '初始合同', 'init'))
    o.children.push(buildMenu(permissionCodes, always, 'contractInitialEdit', 'contractInitialEdit', '', 'contract/business/contractInitial/edit', '初始合同编辑', ''))
    o.children.push(buildMenu(permissionCodes, always, 'contractInitialOperation', 'contractInitialOperation', '', 'contract/business/contractInitial/operation', '合同操作', ''))
    o.children.push(buildMenu(permissionCodes, 'PD0209', 'contractMain', 'contractMain', '', 'contract/business/contractMain/index', '主合同', 'contract_main'))
    o.children.push(buildMenu(permissionCodes, always, 'contractMainEdit', 'contractMainEdit', '', 'contract/business/contractMain/edit', '主合同编辑', ''))
    return o
}

function menuContractExec(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0152', 'exec', 'exec', 'noRedirect', 'ParentView', '合同执行', 'contract')
    o.children.push(buildMenu(permissionCodes, 'PD0175', 'contractInitialBorrow', 'contractInitialBorrow', '', 'contract/exec/contractInitialBorrow/index', '合同借阅', 'borrow'))
    o.children.push(buildMenu(permissionCodes, 'PD0176', 'contractInitialChange', 'contractInitialChange', '', 'contract/exec/contractInitialChange/index', '合同变更', 'change'))
    o.children.push(buildMenu(permissionCodes, 'PD0176', 'contractInitialSupplemental', 'contractInitialSupplemental', '', 'contract/exec/contractInitialSupplemental/index', '合同补充协议', 'supplemental'))
    o.children.push(buildMenu(permissionCodes, 'PD0176', 'contractInitialChecking', 'contractInitialChecking', '', 'contract/exec/contractInitialChecking/index', '合同验收', 'checking'))
    o.children.push(buildMenu(permissionCodes, 'PD0176', 'contractInitialInterrupt', 'contractInitialInterrupt', '', 'contract/exec/contractInitialInterrupt/index', '合同中止', 'interrupt'))
    o.children.push(buildMenu(permissionCodes, 'PD0176', 'contractInitialTerminate', 'contractInitialTerminate', '', 'contract/exec/contractInitialTerminate/index', '合同终止', 'terminate'))
    // o.children.push(buildMenu(permissionCodes, 'PD0176', 'contractInitialArchive', 'contractInitialArchive', '', 'contract/exec/contractInitialArchive/index', '合同归档', 'archive'))
    // o.children.push(buildMenu(permissionCodes, 'PD0176', 'contractInitialAuthorization', 'contractInitialAuthorization', '', 'contract/exec/contractInitialAuthorization/index', '合同授权', 'authorization'))
    // o.children.push(buildMenu(permissionCodes, 'PD0176', 'contractInitialComplete', 'contractInitialComplete', '', 'contract/exec/contractInitialComplete/index', '合同完结', 'complete'))
    // o.children.push(buildMenu(permissionCodes, 'PD0176', 'contractInitialDispute', 'contractInitialDispute', '', 'contract/exec/contractInitialDispute/index', '合同纠纷', 'dispute'))
    // o.children.push(buildMenu(permissionCodes, 'PD0176', 'contractInitialRemind', 'contractInitialRemind', '', 'contract/exec/contractInitialRemind/index', '合同提醒', 'remind'))
    // o.children.push(buildMenu(permissionCodes, 'PD0176', 'contractInitialRestart', 'contractInitialRestart', '', 'contract/exec/contractInitialRestart/index', '合同重启', 'restart'))
    // o.children.push(buildMenu(permissionCodes, 'PD0176', 'contractInitialTracking', 'contractInitialTracking', '', 'contract/exec/contractInitialTracking/index', '合同追踪', 'tracing'))
    // o.children.push(buildMenu(permissionCodes, 'PD0176', 'contractInitialTransfer', 'contractInitialTransfer', '', 'contract/exec/contractInitialTransfer/index', '合同转让', 'transfer'))
    return o
}

function menuContractIncomeExpenditure(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0200', 'expenses', 'expenses', 'noRedirect', 'ParentView', '合同收支', 'expenses')
    o.children.push(buildMenu(permissionCodes, 'PD0201', 'contractOutgoings', 'contractOutgoings', '', 'contract/expenses/contractOutgoings/index', '合同支付', 'outgoings'))
    o.children.push(buildMenu(permissionCodes, 'PD0202', 'contractIncoming', 'contractIncoming', '', 'contract/expenses/contractIncoming/index', '合同收款', 'incoming'))
    return o
}

function menuContractReportForms(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0153', 'reportForms', 'reportForms', 'noRedirect', 'ParentView', '报表查询', 'system-data')
    o.children.push(buildMenu(permissionCodes, 'PD0173', 'comprehensive', 'comprehensive', '', 'contract/reportForms/comprehensive/index', '合同台账', 'monitor'))
    o.children.push(buildMenu(permissionCodes, 'PD0174', 'paymentDetails', 'paymentDetails', '', 'contract/reportForms/paymentDetails/index', '合同付款明细', 'monitor'))
    return o
}
